package com.mdz.nc.Controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mdz.nc.Entity.Sbflb;
import com.mdz.nc.Mapper.SbflbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 孟德志
 * @since 2020-06-28
 */
@Controller
@RequestMapping("/nc/sbflb")
public class SbflbController {

    @Autowired
    private SbflbMapper sbflbMapper;

    @ResponseBody
    @RequestMapping(value = "/getname",method = RequestMethod.GET)
    public List<Sbflb> getname(ModelMap map){
        List<Sbflb> sbflbs=sbflbMapper.getname();
        map.put("sbflbs",sbflbs);
        return sbflbs;
    }

    @ResponseBody
    @RequestMapping(value = "/getnamebyans/{id}",method = RequestMethod.GET)
    public List<Sbflb> getnamebyans(@PathVariable("id") String id){
        List<Sbflb> sbflbs=sbflbMapper.getnamebyans(id);
        return sbflbs;
    }

    @ResponseBody
    @RequestMapping(value = "/maxid/",method = RequestMethod.GET)
    public Integer maxid(){
        return sbflbMapper.maxid();
    }

    @ResponseBody
    @RequestMapping(value = "/getans/{id}",method = RequestMethod.GET)
    public List<Sbflb> getans(@PathVariable("id") String id){
        List<Sbflb> sbflbs=sbflbMapper.selectList(new QueryWrapper<Sbflb>().eq("id",id));
        return sbflbs;
    }

    @ResponseBody
    @RequestMapping(value = "/insertfl", method = RequestMethod.POST)
    public int insertbaof(Sbflb sbflb) {
        sbflb.setFlag("0");
        return sbflbMapper.insert(sbflb);
    }
}

